(define (cont-frac fn fd k)
    (let ( 
            (n (fn k))
            (d (fd k)) 
        )
        (if (= k 1)
            (/ n d)
            (/ n 
                (+ d (cont-frac fn fd (- k 1)))
            )
        )
    )    
)



(define (calc1 k)
    (cont-frac (lambda (i) 1.0) (lambda (i) 1.0) k)
)
(display (calc1 13))
(newline)
(display (calc1 20))
(newline)
(display (calc1 50))
(newline)

(define (cont-frac2 fn fd k)
    (define (iter result count)        
        (let ( 
                (n (fn k))
                (d (fd k)) 
            )
            (if (> count 1)                
                (/ n 
                    (+ d (iter result (- count 1)))
                )
                result
            )
        )
    )
    (iter (/  (fn k) (fd k)) k)    
)
(define (calc2 k)
    (cont-frac2 (lambda (i) 1.0) (lambda (i) 1.0) k)
)
(display (calc2 13))
(exit)
